package com.qingcloud.adminbackend.controller;


import com.qingcloud.adminbackend.base.AjaxResult;
import com.qingcloud.adminbackend.constant.WamingConstant;
import com.qingcloud.adminbackend.entity.sensor.SysSensorFactorConfigDTO;
import com.qingcloud.adminbackend.service.ISysSensorFactorConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 传感器监测因子配置数据表 前端控制器
 * </p>
 *
 * @author liyuhong
 * @since 2019-04-16
 */
@RestController
@RequestMapping("/sys/config/factor")
@Api(value = "监测因子配置API", description = "监测因子配置API")
public class SysSensorFactorConfigController {

    @Resource
    private ISysSensorFactorConfigService sysSensorFactorConfigService;

    @ApiOperation(value = "具体监测因子", notes = "具体监测因子", response = SysSensorFactorConfigDTO.class)
    @PostMapping("/getSensorFactor")
    public AjaxResult getSensorFactor() {
        return new AjaxResult(WamingConstant.SUCCESS, "", sysSensorFactorConfigService.getSensorFactor());
    }

    @ApiOperation(value = "常用监测因子", notes = "常用监测因子", response = SysSensorFactorConfigDTO.class)
    @PostMapping("/getDefaultSensorFactor")
    public AjaxResult getDefaultSensorFactor() {
        return new AjaxResult(WamingConstant.SUCCESS, "", sysSensorFactorConfigService.getDefaultSensorFactor());
    }

    @ApiOperation(value = "获取指定排序类型监测因子列表(1健康空气, 2网格化)", notes = "获取指定排序类型监测因子列表(1健康空气, 2网格化)", response = SysSensorFactorConfigDTO.class)
    @ApiImplicitParam(name = "orderType", value = "排序类型(1健康空气, 2网格化)", dataType = "int", paramType = "query", required = true)
    @GetMapping("/findByOrderType")
    public AjaxResult findByOrderType(@RequestParam("orderType") Integer orderType) {
        return new AjaxResult(WamingConstant.SUCCESS, "",
                sysSensorFactorConfigService.findByOrderType(orderType));
    }

    @ApiOperation(value = "获取校准监测因子列表(1健康空气, 2网格化)", notes = "获取校准监测因子列表(1健康空气, 2网格化)", response = SysSensorFactorConfigDTO.class)
    @ApiImplicitParam(name = "businessType", value = "业务类型(1健康空气, 2网格化)", dataType = "int", paramType = "query", required = true)
    @GetMapping("/findAlineFactor")
    public AjaxResult findAlineFactor(@RequestParam("businessType") Integer businessType) {
        return new AjaxResult(WamingConstant.SUCCESS, "",
                sysSensorFactorConfigService.findAlineFactor(businessType));
    }

    @ApiOperation(value = "获取VOCS监测因子列表(1健康空气, 2网格化)", notes = "获取VOCS监测因子列表(1健康空气, 2网格化)", response = SysSensorFactorConfigDTO.class)
    @ApiImplicitParam(name = "businessType", value = "业务类型(1健康空气, 2网格化)", dataType = "int", paramType = "query", required = true)
    @GetMapping("/findVocsFactor")
    public AjaxResult findVocsFactor(@RequestParam("businessType") Integer businessType) {
        return new AjaxResult(WamingConstant.SUCCESS, "",
                sysSensorFactorConfigService.findVocsFactor(businessType));
    }

    @ApiOperation(value = "通过产品类型获取产品的可用因子", notes = "通过产品类型获取产品的可用因子")
    @ApiImplicitParam(name = "productType", value = "产品类型", dataType = "String", paramType = "path", required = true, defaultValue = "WM-SN100")
    @GetMapping("/findSensorFactorByProductType/{productType}")
    public AjaxResult findSensorFactorByProductType(@PathVariable("productType") String productType) {
        List<SysSensorFactorConfigDTO> result = sysSensorFactorConfigService.findSensorFactorByProductType(productType);
        return new AjaxResult(WamingConstant.SUCCESS, "", result);
    }
}

